/*
 *  (C) Copyright 2007 Insula Tecnologia da Informacao Ltda.
 * 
 *  This file is part of Jazz.
 *
 *  Jazz is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Jazz is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Jazz.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.openinsula.jazz.resolver.echo2;

import static org.junit.Assert.assertEquals;
import nextapp.echo2.app.TextArea;
import nextapp.echo2.app.TextField;

import org.junit.Before;
import org.junit.Test;

public class DefaultTextComponentResolverTestCase {

	private TextField textField = new TextField();

	private TextArea textArea = new TextArea();

	private String phrase = "Long phrase with a lot of text.\nAnother line.";

	private DefaultTextComponentResolver resolver = new DefaultTextComponentResolver();

	@Before
	public void init() {
		textField.setText("Jedi");
		textArea.setText(phrase);
	}

	@Test
	public void testGetValue() {
		assertEquals("Jedi", resolver.getValue(textField));
		assertEquals(phrase, resolver.getValue(textArea));
	}

	@Test
	public void testSetValue() {
		String yanaga = "Yanaga";
		String anotherPhrase = "Another long phrase.\nWith other line.";

		resolver.setValue(textField, yanaga);
		resolver.setValue(textArea, anotherPhrase);

		assertEquals(yanaga, textField.getText());
		assertEquals(anotherPhrase, textArea.getText());
	}

}
